package com.sleep.dao.impl;

import com.sleep.dao.IUserDao;
import com.sleep.model.UserInfoEntity;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by fadinglan on 2017/4/10.
 */
@Repository
public class UserDaoImpl extends BaseDaoImpl<UserInfoEntity, Serializable> implements IUserDao{


    List<UserInfoEntity> userList = new ArrayList<>();

    @Override
    public List<UserInfoEntity> queryUser() {

        String hql = "FROM UserInfoEntity user";
        userList = queryList(hql);
        return userList;
    }

    @Override
    public List<UserInfoEntity> checkAccount(String account) {

        Map<String, Object> params = new HashMap<>();
        params.put("account", account);
        String hql = "FROM UserInfoEntity user WHERE user.vcCellphone = :account";
        userList = find(hql, params);
        return userList;
    }

    @Override
    public List<UserInfoEntity> checkPassword(String password) {

        Map<String, Object> params = new HashMap<>();
        params.put("password", password);
        String hql = "FROM UserInfoEntity user WHERE user.vcPassword = :password";
        userList = find(hql, params);
        return userList;
    }

    @Override
    public List<UserInfoEntity> getUserInfo(String account) {

        Map<String, Object> params = new HashMap<>();

        params.put("account", account);

        String hql = "FROM UserInfoEntity user WHERE user.vcCellphone = :account";

        userList = find(hql, params);

        return userList;
    }

}
